#ifndef GRIDMAP
#define GRIDMAP

#include "grid_rec.h"
//#include "grid.h"
//#include "position.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <map>
#include <queue>
#include <fstream>
#include "../../main_controller.h"

using namespace std;

namespace Group5 {

class Gridmap {

  public:

  map < Position, Grid* > posmap;

  Grid start;
  Grid* current;

  queue<GridRec*> bfq;
    map<Grid, bool> usedmap;

  fstream output;

  Gridmap();
  ~Gridmap();

  void close_output() {
    output.close();
  }

  GridRec* search( Grid* g1, Grid* g2 );
  void go_to(Grid *g);
  Position* current_position() const;
  Grid* move( int direction );
  const bool add_opening( int direction );

  const int inv(int direction) {
    if ( direction == NORTH ) return SOUTH;
    else if ( direction == SOUTH ) return NORTH;
    else if ( direction == EAST) return WEST;
    else return EAST;
  }
  Order* get_order();

  GridRec* current_step_;
  int current_direction;
  Order third_order_;
  Order second_order_;
  Order first_order_;



  // Logging options
  static const bool LOG_PATH_FOLLOWING = true;

};

};

#endif
